package com.gitee.ed.arithmetic.leetcode.question.question_1_100.question_1_10;

import com.gitee.ed.arithmetic.leetcode.SolutionRunner;
import com.gitee.ed.arithmetic.leetcode.common.Question;
import com.gitee.ed.arithmetic.leetcode.solution.solution_1_100.solution_1_10.Solution4;

/**
 * @author hongda.li
 */
public class Question4 implements Question<Solution4> {
    @Override
    public String link() {
        return "https://leetcode.cn/problems/median-of-two-sorted-arrays/description/";
    }

    @Override
    public String title() {
        return "4.寻找两个正序数组的中位数";
    }

    @Override
    public String description() {
        return "给定两个大小分别为 m 和 n 的正序（从小到大）数组 nums1 和 nums2。请你找出并返回这两个正序数组的中位数";
    }

    @Override
    public void test(Solution4 solution) {
        this.test1(solution);

        this.test2(solution);
    }

    private void test1(Solution4 solution) {
        int[] num1 = {1, 3};
        int[] num2 = {2};
        double expect = 2.0d;
        double actual = solution.findMedianSortedArrays(num1, num2);
        SolutionRunner.checkString(expect, actual);
    }

    private void test2(Solution4 solution) {
        int[] num1 = {1, 2};
        int[] num2 = {3, 4};
        double expect = 2.5d;
        double actual = solution.findMedianSortedArrays(num1, num2);
        SolutionRunner.checkString(expect, actual);
    }
}
